<template>
    <el-dialog
      :title="title"
      :visible.sync="previewSrc"
      :width="width"
      v-if="previewSrc"
    >
      <div>
        <img :src="previewSrc" class="preview">
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="closeDialog">关闭</el-button>
      </span>
    </el-dialog>
</template>

<script>
export default {
  name: 'Test',
  props: {
    previewSrc: String, // 图片地址
    width: String,      // 宽度
    title: String,      // 标题
  },
  data(){
    return{
    }
  },
  methods:{
    closeDialog(){
      this.previewSrc="";
    }
  }
}
</script>

<style scoped>
.preview {
  width:100%; 
  height: auto; 
  display:block; 
  margin: 0 auto;  
  min-height: 50px;
}

</style>
